t = int(input())
for _ in range(t):
grid = []
col = int(input())
r1 = list(input())
r2 = list(input())
a = 0
while col > 0:
if r1[0] == '0' and r2[0] == '0' or\
r1[0] == '0' and r2[0] == '1' or\
r1[0] == '1' and r2[0] == '0' :
r1.remove(r1[0])
r2.remove(r2[0])
col -= 1
elif r1[0] == '1' and r2[0] == '1':
r1.remove(r1[0])
r2.remove(r2[0])
col -= 1
a += 1
if a == 0:
print('YES')
else:
print('NO')
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define For(i, s, e) for (ll i = s; i < e; i++)
#define FOR(i, s, e) for (ll i = s; i <= e; i++)
#define FORD(i, s, e) for (ll i = s; i >= e; i--)
#define pb push_back
#define vii vector<ll>
#define makep make_pair
#define vpll vector<pair<ll, ll>>
#define fi first
#define se second
#define sii set<ll>
#define pii pair<int, int>
#define rev(c) reverse(c.begin(), c.end())
#define sortf(c) sort(c.begin(), c.end())
#define sortd(c) sort(c.begin(), c.end(), greater<int>())
#define test() \
int test; \
cin >> test; \
while (test--)
#define fast() \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define sqr(n) (n) * (n)
#define len(s) (s.length())
#define re0 return 0
#define re return
ll const max2d = 1e4 + 7;
ll const N = 1e6 + 7;
ll const inf = 1e9 + 7;
char const nl = '\n';
// ! ¸,ø¤º°`°º¤ø,¸¸,ø¤º° [ нvмegy ] °º¤ø,¸¸,ø¤º°`°º¤ø,¸ roadтoнυe
signed main()
{
fast();
test()
{
int n;
cin >> n;
char a[107], b[107];
FOR(i, 1, n) {
cin >> a[i];
}
FOR(i, 1, n) {
cin >> b[i];
}
bool ck = true;
FOR(i, 1, n) {
if (a[i] == '1' && b[i] == '1') ck = false;
}
cout << (ck ? "YES" : "NO") << nl;
}
return 0;
}
1251B - Binary Palindromes | 768B - Code For 1 |
363B - Fence | 991B - Getting an A |
246A - Buggy Sorting | 884A - Book Reading |
1180A - Alex and a Rhombus | 445A - DZY Loves Chessboard |
1372A - Omkar and Completion | 159D - Palindrome pairs |
981B - Businessmen Problems | 1668A - Direction Change |
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |